/*
 * @Author: zhangyang
 * @Date: 2021-08-26 15:34:41
 * @LastEditTime: 2022-03-10 18:33:17
 * @Description: 登录相关
 */
import { MockApi } from "../decorator/MockApi";
import Mock from 'mockjs';
import nodeInfo from "./nodeInfo";
export class LoginController {
  @MockApi('10000/1')
  static login(params: Record<string, any>) {
    // console.log(params);
    const data = Mock.mock({
      'aid|1-99': 99,
      'token': /(\d|\w){32}/
    });
    return { status: 0, data, msg: 'ok'};
  }

  @MockApi('10000/2') // 退出登录
  @MockApi('10000/4') // 修改密码
  // 通用操作成功
  static common_success(params: Record<string, any>) {
    return { status: 0, data: {}, msg: 'ok'};
  }

  @MockApi('10000/3')
  static getUserInfo(params: Record<string, any>) {
    const data = Mock.mock({
      'admin_name': Mock.Random.word(),
      'real_name': Mock.Random.cname(),
      'autoid|1-99': 99,
      'create_time': Mock.Random.date('yyyy/MM/dd HH:mm:ss'),
      'last_time': Mock.Random.date('yyyy/MM/dd HH:mm:ss'),
      'login_time': Mock.Random.date('yyyy/MM/dd HH:mm:ss'),
      'login_ip': Mock.Random.ip(),
      'is_enable': 1,
      'phone_number': /^1[0-9]{10}$/,
      'role_id': [1],
      'role_name': '超级管理员',
      'menuBar': nodeInfo
    });
    return { status: 0, data, msg: 'ok'};
  }
}
